namespace System.Xml.Serialization
{
    using System.Collections.Generic;

    public abstract class XmlAbstractSerializer
    {
        public static class XmlSerializers
        {
            internal static Dictionary<Type, XmlAbstractSerializer> Serializer = new Dictionary<Type, XmlAbstractSerializer>();
            public static string Serialize(XmlAbstractSerializer seriailzer, object value)
            {
                return Serializer[seriailzer.RuntimeType].Serialize(value);
            }
            public static object Deserialize(XmlAbstractSerializer seriailzer, string value)
            {
                return Serializer[seriailzer.RuntimeType].Deserialize(value);
            }
        }

        private Type _type;
        public XmlAbstractSerializer()
        {
        }
        public Type RuntimeType { get { return _type; } }
        internal void InitializeRuntimeType(Type type)
        {
            _type = type;
        }
        public virtual string Serialize(object value)
        {
            return XmlSerializers.Serialize(this, value);
        }
        public virtual object Deserialize(string value)
        {
            return XmlSerializers.Deserialize(this, value);
        }
    }
}
